/**
 * 框架测试程序
 * 
 * @author Ho Lee
 * @since 2021/7/15
 * @version 0.0.1
 */

package xyz.holee.db.SQLite;

import java.io.File;
import java.sql.*;

public class Sqlite3 {
    public Connection conn;
    public Statement state;
    public boolean isError;
    public boolean isInit;

    public Sqlite3(String fileName, boolean autoCommit) {
        File dbFile = new File(fileName);
        this.isInit = dbFile.isFile();
        this.conn = null;
        this.state = null;
        this.isError = false;
        try {
            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:" + fileName);
            conn.setAutoCommit(autoCommit);
            state = conn.createStatement();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            this.isError = true;
        } catch (SQLException e) {
            e.printStackTrace();
            this.isError = true;
        }
    }
}
